package com.sx.micowell.framework.view.chartManager

import android.graphics.Color
import com.github.mikephil.charting.charts.BarChart
import com.github.mikephil.charting.charts.HorizontalBarChart
import com.github.mikephil.charting.charts.LineChart
import com.github.mikephil.charting.components.XAxis
import com.github.mikephil.charting.components.YAxis
import com.sx.micowell.R
import com.sx.micowell.framework.app.MyApplication
import com.sx.widget.app.DisplayUtil

/**
 * @Description
 * @Author 梁浩文
 * @Date 2021/8/23 18:13
 */


fun XAxis.UI_XAxis() {
    position = XAxis.XAxisPosition.BOTTOM//X轴 位置
    textColor = Color.parseColor("#999999")//X轴 文字颜色
    textSize = DisplayUtil.px2dip(MyApplication.instance(),MyApplication.instance().resources.getDimension(R.dimen.sp_12)).toFloat()//X轴 位置
    yOffset=0f
    granularity = 1f
    axisMinimum=0f
    setDrawGridLines(false)
}

fun YAxis.UI_YAxis() {
    setDrawZeroLine(false)
    textColor = Color.parseColor("#999999")//Y轴 文字颜色
    textSize=DisplayUtil.px2dip(MyApplication.instance(),MyApplication.instance().resources.getDimension(R.dimen.sp_12)).toFloat();//Y轴 文字大小
    axisMinimum=0f
    setDrawGridLines(false)
}

fun LineChart.UI() {
    axisRight.isEnabled=false
    description.isEnabled=false
    legend.isEnabled=false
    isDragEnabled=true
    setNoDataText("暂无数据")
    setScaleEnabled(false)
}


fun XAxis.UI_Chart_XAxis() {
    position = XAxis.XAxisPosition.BOTTOM//X轴 位置
    textColor = Color.parseColor("#999999")//X轴 文字颜色
    textSize = DisplayUtil.px2dip(MyApplication.instance(),MyApplication.instance().resources.getDimension(R.dimen.sp_12)).toFloat()//X轴 位置
    yOffset=0f
    granularity = 1f
    setDrawAxisLine(true)
    setDrawGridLines(false)
}

fun YAxis.UI_Chart_YAxis() {
    setDrawZeroLine(false)
    textColor = Color.parseColor("#999999")//Y轴 文字颜色
    textSize =  DisplayUtil.px2dip(MyApplication.instance(),MyApplication.instance().resources.getDimension(R.dimen.sp_10)).toFloat() //Y轴 文字大小
    axisMinimum = 0f
    granularity = 1f
    setDrawAxisLine(false)
    setDrawGridLines(false)
}

fun BarChart.UIChart() {
    animateY(1500)//动画
    description.isEnabled=false
    legend.isEnabled=false
    isDragEnabled=true
    setPinchZoom(true)
    axisLeft.isEnabled = false
    axisRight.axisMinimum = 0f
    axisRight.setDrawGridLines(false)
    setNoDataText("暂无数据")
    setScaleEnabled(false)
}


fun BarChart.UIBarChart() {
//    animateY(1500)//动画
//    description.isEnabled = false
//    legend.isEnabled = false
//    isDragEnabled = true
//    setScaleEnabled(false)

    animateY(1500)//动画
//    setMaxVisibleValueCount(12)
    description.isEnabled=false
    legend.isEnabled=false
    isDragEnabled=true
    setPinchZoom(true)
    axisRight.isEnabled = false
    axisRight.axisMinimum = 0f
    axisRight.setDrawGridLines(true)
    setNoDataText("暂无数据")
    setScaleEnabled(false)
}

fun XAxis.UI_Bar_XAxis() {
    position = XAxis.XAxisPosition.BOTTOM//X轴 位置
    textColor = Color.parseColor("#999999")//X轴 文字颜色
    textSize =  DisplayUtil.px2dip(MyApplication.instance(),MyApplication.instance().resources.getDimension(R.dimen.sp_12)).toFloat()//X轴 位置
    yOffset=0f
    granularity = 1f

    setDrawAxisLine(true)
    setDrawGridLines(false)
}

fun YAxis.UI_Bar_YAxis() {
    setDrawZeroLine(false)
    textColor = Color.parseColor("#999999")//Y轴 文字颜色
    textSize =  DisplayUtil.px2dip(MyApplication.instance(),MyApplication.instance().resources.getDimension(R.dimen.sp_10)).toFloat() //Y轴 文字大小
    axisMinimum = 0f
    granularity = 1f

    setDrawAxisLine(true)
    setDrawGridLines(false)
}


